from fastapi import APIRouter
from ..services import (
    wikipage_by_title_service, 
    wikitext_by_title_service, 
    wikipage_by_pageid_service,
    wiki_category_members_service,
)

router = APIRouter()


@router.get("/en/query/by-pageid", tags=["wikipedia"])
async def get_wikipedia_page_by_pageid(pageid:int=1028515, cache_ttl:int=60*60*24*365):
    return await wikipage_by_pageid_service.submit_task(pageid, cache_ttl)

@router.get("/en/query/by-title", tags=["wikipedia"])
async def get_wikipedia_page_by_title(title:str,  cache_ttl:int=60*60*24*365):
    return await wikipage_by_title_service.submit_task(title, cache_ttl)

@router.get("/en/parse/by-title", tags=["wikipedia"])
async def get_wikipedia_wikitext_by_title(title:str,  cache_ttl:int=60*60*24*365):
    return await wikitext_by_title_service.submit_task(title, cache_ttl)


@router.get("/en/categorymembers/by-title", tags=["wikipedia"])
async def get_wikipedia_category_members_by_title(title:str="Universities and colleges by year of establishment",  cache_ttl:int=60*60*24*365):
    return await wiki_category_members_service.submit_task(title, cache_ttl)